Skip to content

Handle functools.Placeholder in partial#21399

Open
MestreY0d4-Uninter wants to merge 1 commit intopython:masterfrom
MestreY0d4-Uninter:fix-functools-placeholder
Open

Handle functools.Placeholder in partial#21399
MestreY0d4-Uninter wants to merge 1 commit intopython:masterfrom
MestreY0d4-Uninter:fix-functools-placeholder

Conversation

@MestreY0d4-Uninter
Copy link
Copy Markdown

Fixes #21313.

Summary

This updates the functools.partial plugin to treat functools.Placeholder as an unbound positional slot instead of a normal bound argument.

The generated partial signature now keeps placeholder-backed parameters available for later calls, while still using non-placeholder arguments for type inference.

Test plan

  • PYTHONPATH=. uv run --no-project --isolated --with-requirements test-requirements.txt python -m pytest -q mypy/test/testcheck.py::TypeCheckSuite::check-functools.test
  • PYTHONPATH=. uv run --no-project --isolated --with-requirements test-requirements.txt python -m mypy --config-file mypy_self_check.ini mypy/plugins/functools.py

@github-actions

This comment has been minimized.

@MestreY0d4-Uninter MestreY0d4-Uninter force-pushed the fix-functools-placeholder branch from 36a0b07 to 6bc619f Compare May 4, 2026 21:51
@MestreY0d4-Uninter
Copy link
Copy Markdown
Author

MestreY0d4-Uninter commented May 4, 2026

Pushed 6bc619f to address the mypy_primer INTERNAL ERROR: the partial plugin now avoids direct type-var inference on Unpack/TypeVarTuple arguments while keeping the Placeholder narrowing path.

Local validation:

  • uv run --with-requirements test-requirements.txt python runtests.py check-functools.test — 31 passed
  • uv run --with-requirements test-requirements.txt python runtests.py lint — passed
  • Minimal TypeVarTuple partial repro no longer crashes; it reports normal type errors instead.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MyPy treats Placeholder as _PlaceholderType

1 participant